import os
from PIL import Image
outputdir = '/home/xun/dataset/Best_GEI_128/'
if not os.path.exists(outputdir):
    os.mkdir(outputdir)

inputdir = '/home/xun/dataset/best_GEI_240/gei/'
for identity in os.listdir(inputdir):
    if not os.path.exists(outputdir+identity):
        os.mkdir(outputdir+identity)
    for condition in os.listdir(inputdir+identity):
        if not os.path.exists(outputdir+identity+'/'+condition):
            os.mkdir(outputdir+identity+'/'+condition)
        for picture in os.listdir(inputdir+identity+'/'+condition):
            img = Image.open(inputdir+identity+'/'+condition+'/'+picture)
            img = img.resize((128,128),Image.ANTIALIAS)
            img.save(outputdir+identity+'/'+condition+'/'+picture)
            print('Porcessing :',picture)